
<script type="text/javascript">
$(document).ready(function(){
	$("#upload_now").click(function(){
		ajaxFileUpload();
        return false;
        
	});
	handleDeleteImage();
});

function handleDeleteImage() {
	$("a.ajaxdelete").click(function(){
		if (confirm("<?php echo __("Cancella foto?", $module) ?>"))
		{
		deleteImage(this);
		return false;
		} else {
		return false;
		}
	});
}
function deleteImage(obj) {
	var id = obj.id
	$.post('<?php echo site_url('adozioni/anagrafica/assistiti/foto_ajax_delete')?>',
		{ id: id},
		function(data){
			alert(data);
		}
	);
	$(obj).parent().fadeOut(1000).hide();
}

function ajaxFileUpload() {
	$("#upload_now")
	.ajaxStart(function(){
		//$("img#loading").show();
		$(this).attr("disabled", "true").val('<?php echo __("Attendere...", $module) ?>');
	})
	.ajaxComplete(function(){
		//$("img#loading").hide();
		$(this).val('<?php echo __("Salva foto", $module) ?>').removeAttr("disabled");
	});

	$.ajaxFileUpload
	(
		{
			url:'<?php echo site_url('adozioni/anagrafica/assistiti/foto_ajax_upload/'.$row['id'])?>',
			secureuri:false,
			fileElementId: 'image',
			dataType: 'json',
			success: function (data, status)
			{
				if(typeof(data.error) != 'undefined')
				{
					if(data.error != '')
					{
						alert(data.error);
					}else
					{
						$("#fotolist").append("<div class='boximg' style='display: inline-block; text-align: center; width: 150px; float: left; margin: 5px; '><a href='<?php echo '/img_assistiti/' ?>/"+data.image+"' target='_blank'><img border=0 hspace=10 src='<?php echo '/img_assistiti/s' ?>/"+data.image+"' width='150'></a><br /><strong>"+data.imagedate+"</strong><br /><a href='<?php echo site_url('adozioni/anagrafica/assistiti/delete_image') ?>"+data.imageid+"' class='ajaxdelete' id='"+data.imageid+"'><?php echo __('Elimina', $module) ?></a></div>");
						$("#image").val("");
						handleDeleteImage();
					}
				}
			},
			error: function (data, status, e)
			{
				alert(e);
			}
		}
	)
	return false;
}
</script>

<h1><?php echo $title; ?></h1>
<div class="noprint">
<?php if (isset($notice) || $notice = $this->session->flashdata('notification')):?>
<p class="notice"><?php echo $notice;?></p>
<?php endif;?>




<?php echo anchor('adozioni/anagrafica/assistiti/edit/' . $row['id'], __("Modifica dati personali", $module)) ?> | 
<?php echo anchor('adozioni/anagrafica/assistiti/stampa/' . $row['id'], __("Stampa scheda", $module), array('target' => '_blank')) ?> | 
<?php if($row['attivo'] == 1): ?>
<?php echo anchor('adozioni/anagrafica/assistiti/activate/no/' . $row['id'], __("Passa nello storico", $module)) ?> 
<?php else: ?>
<?php echo anchor('adozioni/anagrafica/assistiti/activate/yes/' . $row['id'], __("Riattiva", $module)) ?> 
<?php endif; ?>

</div>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="form">
  <tr>
    <th class="celeste bold">Data Inserimento </th>
    <td class="item1"><?php echo data($row['data_inserimento']); ?> </td>
  </tr>
  <tr>
    <th class="celeste bold">Stato Assistito</th>
    <td class="item1"><?php echo $row['stato']; ?> </td>
  </tr>
  <tr>
    <th class="celeste bold"><strong>Categoria</strong></th>
    <td class="item1"><?php echo $row['tipo']; ?> </td>
  </tr>
  <tr>
    <th class="bold celeste"><strong>Cognome e Nome </strong></th>
    <td class="item1"><span class="style1"><?php echo $row['nomecognome']; ?> </span></td>
  </tr>
  <tr>
    <th class="celeste bold">Info</th>
    <td class="item1"><?php echo $row['info']; ?> </td>
  </tr>
  <tr>
    <th class="celeste bold"><strong>Sesso</strong></th>
    <td class="item1"><?php echo $row['sesso']; ?> </td>
  </tr>
  <tr>
    <th width="30%" class="bold celeste"><strong>Data e luogo di Nascita </strong></th>
    <td class="item1"> <?php echo data($row['data']); ?>  <?php echo $row['luogo_nascita']; ?>  (<?php echo $row['nazione']; ?> ) </td>
  </tr>
  <tr>
    <th class="bold celeste">Missione</th>
    <td class="item1"><?php echo $row['missione']; ?> </td>
  </tr>
</table>
<br>
<h2>Foto</h2>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="form">
  <tr class="noprint">
    <th width="30%" class="celeste bold"><strong>Aggiungi Nuova Foto</strong></th>
    <td  valign="middle" class="item1"><form action="<?php echo site_url('adozioni/anagrafica/assistiti/save_image/'. $row['id']) ?>" method="post" enctype="multipart/form-data" name="form2">
      <input name="image" type="file" id="image">
      <input type="submit" name="submit" id="upload_now" value="Salva Foto">
      <input name="op" type="hidden" id="op" value="addphoto">
      <input name="id" type="hidden" id="id" value="<?php echo $row['id']; ?> ">
        </form></td>
  </tr>
  <tr>
    <td colspan="2" class="item2"><table  border="0">
      <tr> <td>
      <div id="fotolist">
      <?php if (isset($row['foto']) && !empty($row['foto'])): ?>
	  <?php foreach($row['foto'] as $foto): ?>
	  <div class='boximg' style='display: inline-block; text-align: center; width: 150px; float: left; margin: 5px; '><a href="<?php echo 'http://adozioni.rcj.org/img_assistiti/'. $foto['file']; ?>" target="_blank"><img src="<?php echo 'http://adozioni.rcj.org/img_assistiti/s/'. $foto['file']; ?>" width="150" /></a><br /><strong><?php echo date("d/m/Y", $foto['data']) ?></strong><br /><a href='<?php echo site_url('adozioni/anagrafica/assistiti/delete_image/'. $foto['id']) ?>' class='ajaxdelete' id='<?php echo $foto['id'] ?>'><?php echo __('Elimina', $module) ?></a></div>
	  <?php endforeach; ?>
	  <?php endif; ?>
	  </div>
	  </td></tr>
    </table></td>
  </tr>
  
</table>
<br>
<br> 
<h2>Parentela</h2>
<br>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="form">
  <tr>
    <th class="celeste bold"><strong>Padre</strong></th>
    <td class="item1"><?php echo $row['padre']; ?> </td>
  </tr>
  <tr>
    <th class="bold celeste"><strong>Madre</strong></th>
    <td class="item1"><?php echo $row['madre']; ?> </td>
  </tr>
  <tr>
    <th class="celeste bold"><strong>Responsabile</strong></th>
    <td class="item1"><?php echo $row['responsabile']; ?>  </td>
  </tr>
  <tr>
    <th width="30%" class="bold celeste"><strong>Parentela</strong></th>
    <td class="item1">      <?php echo $row['parentela']; ?> </td>
  </tr>
</table>
<br>
<br> 
<h2>Note</h2>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="form">
  <tr>
    <th width="30%" class="celeste bold" valign="top"><strong>Note</strong></th>
    <td class="item1"><?php echo nl2br($row['note']); ?> </td>
  </tr>
  <tr>
    <th class="bold celeste" valign="top"><strong>Note Riservate </strong></th>
    <td class="item1"><?php echo nl2br($row['note_riservate']); ?> </td>
  </tr>
</table>
<br>

  <br>
  <br>
<h2>Relazioni in corso </h2>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="list">
  <tr>
    <th class="celeste bold">Data Inizio </th>
    <th width="30%" class="celeste bold">Tipo</th>
    <th class="celeste bold">Stato</th>
    <th class="celeste bold"><strong>Sostenitore</strong></th>
    <th class="celeste bold"><strong>Missione</strong></th>
    <th class="celeste bold">&nbsp;</th>
  </tr>
  <?php if($relazioni_in_corso): ?>
  <?php foreach($relazioni_in_corso as $row): ?>
  <tr>
    <td class="{CLASS}"><?php echo data($row['data_inizio']); ?></td>
    <td class="{CLASS}"><?php echo $row['tipo']; ?></td>
    <td class="{CLASS}"><?php echo $row['stato']; ?></td>
    <td class="{CLASS}"><?php echo $row['sostenitore']; ?></td>
    <td class="{CLASS}"><?php echo $row['missione']; ?></td>
    <td class="{CLASS}"><table width="100%"  border="0">
        <tr align="center">
          <td><?php echo anchor('adozioni/anagrafica/adozioni/show/' .  $row['id_adozione'], __("Scheda Relazione", $module)) ?></td>
          <td><?php echo anchor('adozioni/anagrafica/sostenitori/show/' .  $row['id_sostenitore'], __("Scheda Sostenitore", $module)) ?></td>
        </tr>
      </table> </td>
  </tr>
  <?php endforeach; ?>
  <?php endif; ?>
</table>
  <br><br><br>
<h2>Relazioni concluse</h2> 
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="list">
  <tr>
    <th class="celeste bold">Data Inizio </th>
    <th class="celeste bold">Data Fine </th>
    <th class="celeste bold">Tipo</th>
    <th class="celeste bold"><strong>Sostenitore</strong></th>
    <th class="celeste bold"><strong>Missione</strong></th>
    <th class="celeste bold">&nbsp;</th>
  </tr>
  <?php if($relazioni_concluse): ?>
  <?php foreach($relazioni_concluse as $row): ?>
  <tr>
    <td class="{CLASS}"><?php echo data($row['data_inizio']); ?></td>
    <td class="{CLASS}"><?php echo data($row['data_fine']); ?></td>
    <td class="{CLASS}"><?php echo $row['tipo']; ?></td>
    <td class="{CLASS}"><?php echo $row['sostenitore']; ?></td>
    <td class="{CLASS}"><?php echo $row['missione']; ?></td>
    <td class="{CLASS}"><table width="100%"  border="0">
        <tr align="center">
          <td><?php echo anchor('adozioni/anagrafica/adozioni/show/' .  $row['id_adozione'], __("Scheda Relazione", $module)) ?></td>
          <td><?php echo anchor('adozioni/anagrafica/sostenitori/show/' .  $row['id_sostenitore'], __("Scheda Sostenitore", $module)) ?></td>
        </tr>
    </table></td>
  </tr>
  <?php endforeach; ?>
  <?php endif; ?>
</table>
<br><br><br>
<h2>Totali offerte ricevute per anno</h2>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="list">
  <tr>
    <th width="30%" class="celeste bold"><strong>Anno</strong></th>
    <th class="celeste bold"><strong>Totale Lordo</strong></th>
	<th class="celeste bold"><strong>Totale Netto</strong></th>
  </tr>
  <?php if($totali_offerte): ?>
  <?php foreach($totali_offerte as $row): ?>
  <tr>
    <td class="{CLASS}"><?php echo $row['anno']; ?></td>
    <td class="{CLASS}">&euro; <?php echo format_euro($row['totale_l']); ?></td>
	<td class="{CLASS}">&euro; <?php echo format_euro($row['totale_n']); ?></td>
  </tr>
  <?php endforeach; ?>
  <?php endif; ?>
</table>
</body>
</html>
